// SquareLine LVGL GENERATED FILE
// EDITOR VERSION: SquareLine Studio 1.1.0
// LVGL VERSION: 8.2
// PROJECT: SquareLine_Project

#include "ui.h"
#include "ui_helpers.h"
#include "ui_comp.h"

///////////////////// VARIABLES ////////////////////
lv_obj_t * ui_Screen1;
lv_obj_t * ui_Panel1;
lv_obj_t * ui_Chart1;
lv_obj_t * ui_Label1;
lv_obj_t * ui_Label2;
lv_obj_t * ui_input1;
void ui_event_Dropdown1(lv_event_t * e);
lv_obj_t * ui_Dropdown1;
lv_obj_t * ui_btnGroup;
void ui_event_pauseBtn(lv_event_t * e);
lv_obj_t * ui_pauseBtn;
void ui_event_playBtn(lv_event_t * e);
lv_obj_t * ui_playBtn;
void ui_event_nextBtn(lv_event_t * e);
lv_obj_t * ui_nextBtn;
void ui_event_prevBtn(lv_event_t * e);
lv_obj_t * ui_prevBtn;
void ui_event_Button1(lv_event_t * e);
lv_obj_t * ui_Button1;
lv_obj_t * ui_ON_Text;
lv_obj_t * ui_OFF_Text;
void ui_event_Button2(lv_event_t * e);
lv_obj_t * ui_Button2;
lv_obj_t * ui_ON_Text1;
lv_obj_t * ui_OFF_Text1;
lv_obj_t * ui_VOLUME_MODIFY;
lv_obj_t * ui_INPUT_VOLUME;
void ui_event_SLIDER_INPUT(lv_event_t * e);
lv_obj_t * ui_SLIDER_INPUT;
lv_obj_t * ui_MUSIC_VOLUME;
void ui_event_SLIDER_MUSIC(lv_event_t * e);
lv_obj_t * ui_SLIDER_MUSIC;

///////////////////// TEST LVGL SETTINGS ////////////////////
#if LV_COLOR_DEPTH != 16
    #error "LV_COLOR_DEPTH should be 16bit to match SquareLine Studio's settings"
#endif
#if LV_COLOR_16_SWAP !=0
    #error "LV_COLOR_16_SWAP should be 0 to match SquareLine Studio's settings"
#endif

///////////////////// ANIMATIONS ////////////////////

///////////////////// FUNCTIONS ////////////////////
void ui_event_Dropdown1(lv_event_t * e)
{
    lv_event_code_t event_code = lv_event_get_code(e);
    lv_obj_t * target = lv_event_get_target(e);
    if(event_code == LV_EVENT_VALUE_CHANGED) {
        onDropDownChange(e);
    }
}
void ui_event_pauseBtn(lv_event_t * e)
{
    lv_event_code_t event_code = lv_event_get_code(e);
    lv_obj_t * target = lv_event_get_target(e);
    if(event_code == LV_EVENT_CLICKED) {
        PlayMusic(e);
        _ui_flag_modify(ui_playBtn, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
        _ui_flag_modify(ui_pauseBtn, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
    }
}
void ui_event_playBtn(lv_event_t * e)
{
    lv_event_code_t event_code = lv_event_get_code(e);
    lv_obj_t * target = lv_event_get_target(e);
    if(event_code == LV_EVENT_CLICKED) {
        PauseMusic(e);
        _ui_flag_modify(ui_playBtn, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
        _ui_flag_modify(ui_playBtn, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_ADD);
        _ui_flag_modify(ui_pauseBtn, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
    }
}
void ui_event_nextBtn(lv_event_t * e)
{
    lv_event_code_t event_code = lv_event_get_code(e);
    lv_obj_t * target = lv_event_get_target(e);
    if(event_code == LV_EVENT_CLICKED) {
        playNextMusic(e);
    }
}
void ui_event_prevBtn(lv_event_t * e)
{
    lv_event_code_t event_code = lv_event_get_code(e);
    lv_obj_t * target = lv_event_get_target(e);
    if(event_code == LV_EVENT_CLICKED) {
        playLastMusic(e);
    }
}
void ui_event_Button1(lv_event_t * e)
{
    lv_event_code_t event_code = lv_event_get_code(e);
    lv_obj_t * target = lv_event_get_target(e);
    if(event_code == LV_EVENT_CLICKED) {
        _ui_flag_modify(ui_ON_Text, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
        _ui_flag_modify(ui_OFF_Text, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
        toggleInputStatus(e);
    }
}
void ui_event_Button2(lv_event_t * e)
{
    lv_event_code_t event_code = lv_event_get_code(e);
    lv_obj_t * target = lv_event_get_target(e);
    if(event_code == LV_EVENT_CLICKED) {
        _ui_flag_modify(ui_ON_Text1, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
        _ui_flag_modify(ui_OFF_Text1, LV_OBJ_FLAG_HIDDEN, _UI_MODIFY_FLAG_TOGGLE);
        toggleMuteStatus(e);
    }
}
void ui_event_SLIDER_INPUT(lv_event_t * e)
{
    lv_event_code_t event_code = lv_event_get_code(e);
    lv_obj_t * target = lv_event_get_target(e);
    if(event_code == LV_EVENT_VALUE_CHANGED) {
        onInputVolumeChange(e);
    }
}
void ui_event_SLIDER_MUSIC(lv_event_t * e)
{
    lv_event_code_t event_code = lv_event_get_code(e);
    lv_obj_t * target = lv_event_get_target(e);
    if(event_code == LV_EVENT_VALUE_CHANGED) {
        onMusicVolumeChange(e);
    }
}

///////////////////// SCREENS ////////////////////
void ui_Screen1_screen_init(void)
{
    ui_Screen1 = lv_obj_create(NULL);
    lv_obj_clear_flag(ui_Screen1, LV_OBJ_FLAG_SCROLLABLE);      /// Flags

    ui_Panel1 = lv_obj_create(ui_Screen1);
    lv_obj_set_width(ui_Panel1, 480);
    lv_obj_set_height(ui_Panel1, 272);
    lv_obj_set_align(ui_Panel1, LV_ALIGN_CENTER);
    lv_obj_clear_flag(ui_Panel1, LV_OBJ_FLAG_SCROLLABLE);      /// Flags

    ui_Chart1 = lv_chart_create(ui_Panel1);
    lv_obj_set_width(ui_Chart1, 480);
    lv_obj_set_height(ui_Chart1, 272);
    lv_obj_set_align(ui_Chart1, LV_ALIGN_CENTER);

    ui_Label1 = lv_label_create(ui_Panel1);
    lv_obj_set_width(ui_Label1, LV_SIZE_CONTENT);   /// 1
    lv_obj_set_height(ui_Label1, LV_SIZE_CONTENT);    /// 1
    lv_obj_set_x(ui_Label1, 144);
    lv_obj_set_y(ui_Label1, 65);
    lv_obj_set_align(ui_Label1, LV_ALIGN_CENTER);
    lv_label_set_text(ui_Label1, "KTV PLATFORM");
    lv_obj_set_style_text_color(ui_Label1, lv_color_hex(0x001AB1), LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_text_opa(ui_Label1, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_border_color(ui_Label1, lv_color_hex(0x001AB1), LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_border_opa(ui_Label1, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_border_width(ui_Label1, 2, LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_border_side(ui_Label1, LV_BORDER_SIDE_BOTTOM, LV_PART_MAIN | LV_STATE_DEFAULT);

    ui_Label2 = lv_label_create(ui_Panel1);
    lv_obj_set_width(ui_Label2, LV_SIZE_CONTENT);   /// 1
    lv_obj_set_height(ui_Label2, LV_SIZE_CONTENT);    /// 1
    lv_obj_set_x(ui_Label2, 147);
    lv_obj_set_y(ui_Label2, 100);
    lv_obj_set_align(ui_Label2, LV_ALIGN_CENTER);
    lv_label_set_text(ui_Label2, "19211388 CZY\n19221069 LZAY");
    lv_obj_set_style_text_color(ui_Label2, lv_color_hex(0x747474), LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_text_opa(ui_Label2, 255, LV_PART_MAIN | LV_STATE_DEFAULT);
    lv_obj_set_style_text_align(ui_Label2, LV_TEXT_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT);

    ui_input1 = lv_textarea_create(ui_Panel1);
    lv_obj_set_width(ui_input1, 143);
    lv_obj_set_height(ui_input1, LV_SIZE_CONTENT);    /// 36
    lv_obj_set_x(ui_input1, -150);
    lv_obj_set_y(ui_input1, -95);
    lv_obj_set_align(ui_input1, LV_ALIGN_CENTER);
    lv_textarea_set_placeholder_text(ui_input1, "Status");
    lv_textarea_set_one_line(ui_input1, true);
    lv_obj_clear_flag(ui_input1, LV_OBJ_FLAG_SCROLLABLE | LV_OBJ_FLAG_SCROLL_ELASTIC | LV_OBJ_FLAG_SCROLL_MOMENTUM |
                      LV_OBJ_FLAG_SCROLL_CHAIN);     /// Flags

    ui_Dropdown1 = lv_dropdown_create(ui_Panel1);
    lv_dropdown_set_options(ui_Dropdown1, "");
    lv_obj_set_width(ui_Dropdown1, 274);
    lv_obj_set_height(ui_Dropdown1, LV_SIZE_CONTENT);    /// 1
    lv_obj_set_x(ui_Dropdown1, 75);
    lv_obj_set_y(ui_Dropdown1, -95);
    lv_obj_set_align(ui_Dropdown1, LV_ALIGN_CENTER);
    lv_obj_add_flag(ui_Dropdown1, LV_OBJ_FLAG_SCROLL_ON_FOCUS);     /// Flags

    ui_btnGroup = lv_obj_create(ui_Panel1);
    lv_obj_set_width(ui_btnGroup, 246);
    lv_obj_set_height(ui_btnGroup, 71);
    lv_obj_set_x(ui_btnGroup, -98);
    lv_obj_set_y(ui_btnGroup, 82);
    lv_obj_set_align(ui_btnGroup, LV_ALIGN_CENTER);
    lv_obj_clear_flag(ui_btnGroup, LV_OBJ_FLAG_SCROLLABLE);      /// Flags

    ui_pauseBtn = lv_imgbtn_create(ui_btnGroup);
    lv_imgbtn_set_src(ui_pauseBtn, LV_IMGBTN_STATE_RELEASED, NULL, &ui_img_733259054, NULL);
    lv_imgbtn_set_src(ui_pauseBtn, LV_IMGBTN_STATE_PRESSED, NULL, &ui_img_855638741, NULL);
    lv_obj_set_height(ui_pauseBtn, 64);
    lv_obj_set_width(ui_pauseBtn, LV_SIZE_CONTENT);   /// 1
    lv_obj_set_align(ui_pauseBtn, LV_ALIGN_CENTER);
    lv_obj_add_flag(ui_pauseBtn, LV_OBJ_FLAG_HIDDEN);     /// Flags

    ui_playBtn = lv_imgbtn_create(ui_btnGroup);
    lv_imgbtn_set_src(ui_playBtn, LV_IMGBTN_STATE_RELEASED, NULL, &ui_img_1356924652, NULL);
    lv_imgbtn_set_src(ui_playBtn, LV_IMGBTN_STATE_PRESSED, NULL, &ui_img_1510738853, NULL);
    lv_obj_set_height(ui_playBtn, 64);
    lv_obj_set_width(ui_playBtn, LV_SIZE_CONTENT);   /// 1
    lv_obj_set_align(ui_playBtn, LV_ALIGN_CENTER);

    ui_nextBtn = lv_imgbtn_create(ui_btnGroup);
    lv_imgbtn_set_src(ui_nextBtn, LV_IMGBTN_STATE_RELEASED, NULL, &ui_img_12227111, NULL);
    lv_imgbtn_set_src(ui_nextBtn, LV_IMGBTN_STATE_PRESSED, NULL, &ui_img_872380032, NULL);
    lv_obj_set_height(ui_nextBtn, 64);
    lv_obj_set_width(ui_nextBtn, LV_SIZE_CONTENT);   /// 1
    lv_obj_set_x(ui_nextBtn, 77);
    lv_obj_set_y(ui_nextBtn, 1);
    lv_obj_set_align(ui_nextBtn, LV_ALIGN_CENTER);

    ui_prevBtn = lv_imgbtn_create(ui_btnGroup);
    lv_imgbtn_set_src(ui_prevBtn, LV_IMGBTN_STATE_RELEASED, NULL, &ui_img_366645947, NULL);
    lv_imgbtn_set_src(ui_prevBtn, LV_IMGBTN_STATE_PRESSED, NULL, &ui_img_1161088148, NULL);
    lv_obj_set_height(ui_prevBtn, 64);
    lv_obj_set_width(ui_prevBtn, LV_SIZE_CONTENT);   /// 1
    lv_obj_set_x(ui_prevBtn, -77);
    lv_obj_set_y(ui_prevBtn, 1);
    lv_obj_set_align(ui_prevBtn, LV_ALIGN_CENTER);

    ui_Button1 = lv_btn_create(ui_Panel1);
    lv_obj_set_width(ui_Button1, 106);
    lv_obj_set_height(ui_Button1, 38);
    lv_obj_set_x(ui_Button1, 168);
    lv_obj_set_y(ui_Button1, -42);
    lv_obj_set_align(ui_Button1, LV_ALIGN_CENTER);
    lv_obj_add_flag(ui_Button1, LV_OBJ_FLAG_SCROLL_ON_FOCUS);     /// Flags
    lv_obj_clear_flag(ui_Button1, LV_OBJ_FLAG_SCROLLABLE);      /// Flags

    ui_ON_Text = lv_label_create(ui_Button1);
    lv_obj_set_width(ui_ON_Text, LV_SIZE_CONTENT);   /// 1
    lv_obj_set_height(ui_ON_Text, LV_SIZE_CONTENT);    /// 1
    lv_obj_set_x(ui_ON_Text, -1);
    lv_obj_set_y(ui_ON_Text, 0);
    lv_obj_set_align(ui_ON_Text, LV_ALIGN_CENTER);
    lv_label_set_text(ui_ON_Text, "INPUT: ON");

    ui_OFF_Text = lv_label_create(ui_Button1);
    lv_obj_set_width(ui_OFF_Text, LV_SIZE_CONTENT);   /// 1
    lv_obj_set_height(ui_OFF_Text, LV_SIZE_CONTENT);    /// 1
    lv_obj_set_x(ui_OFF_Text, -1);
    lv_obj_set_y(ui_OFF_Text, 0);
    lv_obj_set_align(ui_OFF_Text, LV_ALIGN_CENTER);
    lv_label_set_text(ui_OFF_Text, "INPUT: OFF");
    lv_obj_add_flag(ui_OFF_Text, LV_OBJ_FLAG_HIDDEN);     /// Flags

    ui_Button2 = lv_btn_create(ui_Panel1);
    lv_obj_set_width(ui_Button2, 106);
    lv_obj_set_height(ui_Button2, 38);
    lv_obj_set_x(ui_Button2, 168);
    lv_obj_set_y(ui_Button2, 2);
    lv_obj_set_align(ui_Button2, LV_ALIGN_CENTER);
    lv_obj_add_flag(ui_Button2, LV_OBJ_FLAG_SCROLL_ON_FOCUS);     /// Flags
    lv_obj_clear_flag(ui_Button2, LV_OBJ_FLAG_SCROLLABLE);      /// Flags

    ui_ON_Text1 = lv_label_create(ui_Button2);
    lv_obj_set_width(ui_ON_Text1, LV_SIZE_CONTENT);   /// 1
    lv_obj_set_height(ui_ON_Text1, LV_SIZE_CONTENT);    /// 1
    lv_obj_set_x(ui_ON_Text1, -1);
    lv_obj_set_y(ui_ON_Text1, 0);
    lv_obj_set_align(ui_ON_Text1, LV_ALIGN_CENTER);
    lv_label_set_text(ui_ON_Text1, "MUTE: OFF");

    ui_OFF_Text1 = lv_label_create(ui_Button2);
    lv_obj_set_width(ui_OFF_Text1, LV_SIZE_CONTENT);   /// 1
    lv_obj_set_height(ui_OFF_Text1, LV_SIZE_CONTENT);    /// 1
    lv_obj_set_x(ui_OFF_Text1, -1);
    lv_obj_set_y(ui_OFF_Text1, 0);
    lv_obj_set_align(ui_OFF_Text1, LV_ALIGN_CENTER);
    lv_label_set_text(ui_OFF_Text1, "MUTE: ON");
    lv_obj_add_flag(ui_OFF_Text1, LV_OBJ_FLAG_HIDDEN);     /// Flags

    ui_VOLUME_MODIFY = lv_obj_create(ui_Panel1);
    lv_obj_set_width(ui_VOLUME_MODIFY, 322);
    lv_obj_set_height(ui_VOLUME_MODIFY, 89);
    lv_obj_set_x(ui_VOLUME_MODIFY, -61);
    lv_obj_set_y(ui_VOLUME_MODIFY, -20);
    lv_obj_set_align(ui_VOLUME_MODIFY, LV_ALIGN_CENTER);
    lv_obj_clear_flag(ui_VOLUME_MODIFY, LV_OBJ_FLAG_SCROLLABLE);      /// Flags

    ui_INPUT_VOLUME = lv_label_create(ui_VOLUME_MODIFY);
    lv_obj_set_width(ui_INPUT_VOLUME, LV_SIZE_CONTENT);   /// 1
    lv_obj_set_height(ui_INPUT_VOLUME, LV_SIZE_CONTENT);    /// 1
    lv_obj_set_x(ui_INPUT_VOLUME, -91);
    lv_obj_set_y(ui_INPUT_VOLUME, 17);
    lv_obj_set_align(ui_INPUT_VOLUME, LV_ALIGN_CENTER);
    lv_label_set_text(ui_INPUT_VOLUME, "Input Volume");

    ui_SLIDER_INPUT = lv_slider_create(ui_VOLUME_MODIFY);
    lv_slider_set_value(ui_SLIDER_INPUT, 50, LV_ANIM_OFF);
    if(lv_slider_get_mode(ui_SLIDER_INPUT) == LV_SLIDER_MODE_RANGE) lv_slider_set_left_value(ui_SLIDER_INPUT, 0,
                                                                                                 LV_ANIM_OFF);
    lv_obj_set_width(ui_SLIDER_INPUT, 143);
    lv_obj_set_height(ui_SLIDER_INPUT, 7);
    lv_obj_set_x(ui_SLIDER_INPUT, 59);
    lv_obj_set_y(ui_SLIDER_INPUT, 16);
    lv_obj_set_align(ui_SLIDER_INPUT, LV_ALIGN_CENTER);

    ui_MUSIC_VOLUME = lv_label_create(ui_VOLUME_MODIFY);
    lv_obj_set_width(ui_MUSIC_VOLUME, LV_SIZE_CONTENT);   /// 1
    lv_obj_set_height(ui_MUSIC_VOLUME, LV_SIZE_CONTENT);    /// 1
    lv_obj_set_x(ui_MUSIC_VOLUME, -89);
    lv_obj_set_y(ui_MUSIC_VOLUME, -16);
    lv_obj_set_align(ui_MUSIC_VOLUME, LV_ALIGN_CENTER);
    lv_label_set_text(ui_MUSIC_VOLUME, "Music Volume");

    ui_SLIDER_MUSIC = lv_slider_create(ui_VOLUME_MODIFY);
    lv_slider_set_value(ui_SLIDER_MUSIC, 50, LV_ANIM_OFF);
    if(lv_slider_get_mode(ui_SLIDER_MUSIC) == LV_SLIDER_MODE_RANGE) lv_slider_set_left_value(ui_SLIDER_MUSIC, 0,
                                                                                                 LV_ANIM_OFF);
    lv_obj_set_width(ui_SLIDER_MUSIC, 143);
    lv_obj_set_height(ui_SLIDER_MUSIC, 7);
    lv_obj_set_x(ui_SLIDER_MUSIC, 59);
    lv_obj_set_y(ui_SLIDER_MUSIC, -16);
    lv_obj_set_align(ui_SLIDER_MUSIC, LV_ALIGN_CENTER);

    lv_obj_add_event_cb(ui_Dropdown1, ui_event_Dropdown1, LV_EVENT_ALL, NULL);
    lv_obj_add_event_cb(ui_pauseBtn, ui_event_pauseBtn, LV_EVENT_ALL, NULL);
    lv_obj_add_event_cb(ui_playBtn, ui_event_playBtn, LV_EVENT_ALL, NULL);
    lv_obj_add_event_cb(ui_nextBtn, ui_event_nextBtn, LV_EVENT_ALL, NULL);
    lv_obj_add_event_cb(ui_prevBtn, ui_event_prevBtn, LV_EVENT_ALL, NULL);
    lv_obj_add_event_cb(ui_Button1, ui_event_Button1, LV_EVENT_ALL, NULL);
    lv_obj_add_event_cb(ui_Button2, ui_event_Button2, LV_EVENT_ALL, NULL);
    lv_obj_add_event_cb(ui_SLIDER_INPUT, ui_event_SLIDER_INPUT, LV_EVENT_ALL, NULL);
    lv_obj_add_event_cb(ui_SLIDER_MUSIC, ui_event_SLIDER_MUSIC, LV_EVENT_ALL, NULL);

}

void ui_init(void)
{
    // LV_EVENT_GET_COMP_CHILD = lv_event_register_id();

    lv_disp_t * dispp = lv_disp_get_default();
    lv_theme_t * theme = lv_theme_default_init(dispp, lv_palette_main(LV_PALETTE_BLUE), lv_palette_main(LV_PALETTE_RED),
                                               false, LV_FONT_DEFAULT);
    lv_disp_set_theme(dispp, theme);
    ui_Screen1_screen_init();
    lv_disp_load_scr(ui_Screen1);
}
